
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.Partitioner;


public class ReduceBucketPartitioner implements Partitioner<Text,Text>{
	JobConf conf;

	@Override
	public int getPartition(Text key, Text value, int numPartitions) {
		if (value.toString().compareTo("")==0)
		{
			return 16%numPartitions;
		}
		else 
		{
			if (Integer.parseInt(value.toString())<=67108863)
			{
				return 0;
			}
			else return (int) (Math.floor(Integer.parseInt(value.toString())/67108864))%numPartitions;
		}
	}

	@Override
	public void configure(JobConf job) {
		// TODO Auto-generated method stub
		conf = job;
		
	}

}
